{$, View} = require 'atom'
_ = require 'underscore'
ChooserView = require '../utils/chooser-view'
###
class TemplateTreeView extends View
  @content: ->
    @ul class: 'list-tree', =>
      @li class: 'list-nested-item', =>
        @div class: 'list-item', =>
          @span class: 'icon icon-file-directory', 'HTML5 Application'
        @ul class: 'list-tree', =>
          @li class: 'list-item', =>
            @span class: 'icon icon-file-text', 'aaa'
###
AmazeUITemplates = [
  {id: 'list', name: '列表模板', glyphicon: 'glyphicon-bold', description: '使用AmazeUI框架的列表模板构建项目'}
  {id: 'widget', name: '组件模板', glyphicon: 'glyphicon-align-center', description: '使用AmazeUI框架的组件模板构建项目'}
  {id: 'empty_amz', name: '空模板', glyphicon: 'glyphicon-align-center', description: '使用AmazeUI框架构建空项目'}
]

ButterflyTemplates = [
  ##{id: 'simple', name: '简单', glyphicon: 'glyphicon-bold', description: '使用Butterfly框架构建简单项目'}
  {id: 'modular', name: '模块化', glyphicon: 'glyphicon-align-center', description: '使用Butterfly框架中的各种组件构件复杂项目'}
  {id: 'empty_btf', name: '空模板', glyphicon: 'glyphicon-align-center', description: '使用Butterfly框架构建空项目'}
]

module.exports =
class TemplateChooserView extends View
  @content: ->
    @div =>
      @subview 'chooser', new ChooserView(title: 'Choose a template for your new project:', ButterflyItems: ButterflyTemplates, AmazeUIItems: AmazeUITemplates)

  attachTo: (parentView) ->
    parentView.append(this)
    @chooser.selectFirstItemView()

  destroy: ->
    @detach()

  onNext: (wizard) ->
    if @chooser.getSelectedItem().description.indexOf("Butterfly") > -1
       type = "Butterfly"
    else
      type = "AmazeUI"
    wizard.mergeOptions {'template': @chooser.getSelectedItem().id}
    wizard.mergeOptions {'type': type}
    wizard.nextStep()
